package cn.snow.iot.module.warning.service.config;


import cn.snow.iot.module.warning.controller.admin.config.vo.WarningSaveVO;
import cn.snow.iot.module.warning.dal.dataobject.config.ConfigActionDO;
import cn.snow.iot.module.warning.dal.mysql.config.ConfigActionMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ConfigActionServiceImpl extends ServiceImpl<ConfigActionMapper, ConfigActionDO> implements IConfigActionService {

    @Override
    public void updateAction(WarningSaveVO warningSaveVO) {
        Long id = warningSaveVO.getId();
        baseMapper.deleteByWarningId(id);
        List<ConfigActionDO> actionDOList = warningSaveVO.getActionDOList();
        saveBatch(actionDOList);
    }

    @Override
    public void deleteByConfigId(Long id) {
        baseMapper.deleteByWarningId(id);
    }

    @Override
    public List<ConfigActionDO> getActionByConfigId(Long id) {
        return baseMapper.selectByConfigId(id);
    }
}
